***Replication Materials for:
*Nonnemacher, Jeffrey. "Do Voters Pay Attention to Transnational Politics? Party Positions, Transnational Families, and Voter Perceptions"
*BJPS

******
*CSES*
******

*use "/BJPS_CSES_Replication.dta"

//Figure 1
twoway (scatter  rile pfam_avg if n_pfam==10, mcolor(red)) ///
		(scatter rile pfam_avg if n_pfam==2, mcolor(black)) ///
		(scatter rile pfam_avg if n_pfam==3, mcolor(blue)) ///
		(scatter rile pfam_avg if n_pfam==4, mcolor(green)) ///
		(scatter rile pfam_avg if n_pfam==7, mcolor(yellow)) ///
		(scatter rile pfam_avg if n_pfam==6, mcolor(pink)) ///
		(scatter rile pfam_avg if n_pfam==8, mcolor(purple)) ///
		(scatter rile pfam_avg if n_pfam==1, mcolor(orange)) ///
		|| function y = x, ra(pfam_avg) 
		
//Table 1
xtmixed misperception_cmp pfamdiv_change_dir pfam_shift partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle
estimates store table1

margins, at (pfamdiv_change_dir=(-2 0 2))

//Figure 2
gen newvar_t1m3=1.10
gen pfamdiv_cX=pfamdiv_change_dir
estimates restore table1

margins, at (pfamdiv_change_dir=(-3 (1) 4))
marginsplot, addplot (spike newvar_t1m3 pfamdiv_change_dir) level(95)

**Appendix

//Table A1
sum misperception_cmp pfamdiv_change_dir partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 pfamdiv_dir pfamdiv_change_dir pfam_shift

//Table A2
estimates restore table1
estat sum misperception_cmp pfamdiv_change_dir partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 pfamdiv_dir pfamdiv_change_dir pfam_shift

//Table A3
*Data available upon request.

//Table A4
xtmixed misperception_ches pfamdiv_ches partyage pol_info self_rile female educ age distance_ches pid size mag_shift_ches radical_ches enep2 i.n_pfam_ches i.eyear i.n_cntry, ||ches_party_code:, var mle
xtmixed misperception_ches pfamdiv_change_dir_ches pfam_shift_ches partyage pol_info self_rile female educ age distance_ches pid size mag_shift_ches radical_ches enep2 i.n_pfam_ches i.eyear i.n_cntry, ||ches_party_code:, var mle

//Table A5
xtmixed misperception_cmp pfamdiv_no_outliers partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle
xtmixed misperception_cmp pfamdiv_yr1 partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle
xtmixed misperception_cmp pfamdiv_mid partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle

//Table A6
xtmixed misperception_cmp pfamdiv_change_no pfam_shift_no partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle
xtmixed misperception_cmp pfamdiv_change_yr1 pfam_shift_yr1 partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle
xtmixed misperception_cmp pfamdiv_change_mid pfam_shift_mid partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle

//Table A7
xtmixed misperception_cmp pfamdiv partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle

//Table A8
xtmixed pfamdiv_perc pfamdiv partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle

//Table A9
xtmixed misperception_cmp pfamdiv_perc pfamdiv partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle

//Table A10
xtmixed misperception_cmp  c.pfamdiv_dir##c.pfamdiv_dir##i.left partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry, ||cmp_party_code:, var mle
estimates store tableA10

//Figure A1
gen newvar_f5=0.45
gen pfamdiv_dirL=pfamdiv_dir if left==1
gen pfamdiv_dirR=pfamdiv_dir if left==0

*Panel 1- Left Parties
estimates restore tableA10
margins, at (pfamdiv_dir=(-5 (0.5) 5) left=(1))
marginsplot, addplot (spike newvar_f5 pfamdiv_dirL) level(95)
graph save Graph "/Users/jeffreynonnemacher/Desktop/Figure 5L.gph",replace
graph rename Graph figure5L, replace

*Panel 2- Right Parties
margins, at (pfamdiv_dir=(-5 (0.5) 5) left=(0))
marginsplot, addplot (spike newvar_f5 pfamdiv_dirR) level(95)
graph save Graph "/Users/jeffreynonnemacher/Desktop/Figure 5R.gph",replace
graph rename Graph figure5R, replace

graph combine figure5L figure5R, name(figure5, replace) ycommon

//FN 21
xtmixed misperception_cmp c.pfamdiv partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry if pfamdiv<=4, ||cmp_party_code:, var mle
xtmixed misperception_cmp c.pfamdiv_change_dir pfam_shift partyage pol_info self_rile female educ age distance pid size w_rile mag_shift radical enep2 i.n_pfam i.eyear i.n_cntry if pfamdiv<=4, ||cmp_party_code:, var mle


******
*GLES*
******

*use "/BJPS_GLES_Replication.dta"

//Table 2
xtmixed misperception pfam_div_change p_pfamdiv pfam_shift misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle

**Appendix

//Table A11
sum misperception pfam_div_change p_pfamdiv pfam_div pfam_shift misperc_lag female age size self_rile2 distance shift voter govt

//Table A12
xtmixed misperception pfam_div p_pfamdiv misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle

//Table A13
xtmixed misperception perc_div p_perc_div misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
xtmixed misperception perc_div_change pfam_shift misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle

//Table A14
xtmixed misperception pfam_div_no_outliers prev_pfam_div_no_outliers misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
xtmixed misperception pfam_div_yr1 prev_pfam_div_yr1 misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
xtmixed misperception pfam_div_mid prev_pfam_div_mid misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle

//Table A15
xtmixed misperception pfam_div_no_outliers_change prev_pfam_div_no_outliers pfam_shift_no_outliers misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
xtmixed misperception pfam_div_yr1_change prev_pfam_div_yr1 pfam_shift_yr1 misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
xtmixed misperception pfam_div_mid_change prev_pfam_div_mid pfam_shift_mid misperc_lag female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle

//Table A16
xtmixed perc_div pfam_div p_perc_div  p_pfamdiv female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
xtmixed perc_div pfam_div_change pfam_shift p_perc_div female age size self_rile2 distance shift voter  govt i.eyear i.n_pfam, ||respid:, var mle
